package com.mdxl.shiro.util;

import java.util.Random;

/**
 * @Author:MuJiuTian
 * @Description:
 * @Date: Created in 上午9:43 2019/11/4
 */
public class CommonUtil {

    private static final String randChars = "0123456789abcdefghigklmnopqrstuvtxyzABCDEFGHIGKLMNOPQRSTUVWXYZ";

    //随机字符串
    public static String getRandStr(int length, boolean isOnlyNum) {
        int size = isOnlyNum ? 10 : 62;
        StringBuffer hash = new StringBuffer(length);
        for (int i = 0; i < length; i++) {
            hash.append(randChars.charAt(new Random().nextInt(size)));
        }
        return hash.toString();
    }
}
